<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>产品库存预警分析</title>
    <script type="text/javascript">
      Ext.onReady(function(){
               
        var submitButton = new Ext.Button({
          text: '执行统计',
          iconCls: 'finding',
          handler: function(){
            if (queryFormPanel.form.isValid()) {
              statsResultDS.removeAll();
              statsResultDS.load();
            }
          }
        });

        var queryFormPanel = new Ext.form.FormPanel({
          //baseCls: 'x-plain',
          //renderTo: 'query_form',
          labelWidth: 65,
          width: screenWidth-175,
          labelAlign: 'right',
          frame : true,
          border:false,
          items: [submitButton]
        });
        //显示销售订单操作时的窗口介面。
        //----------------------------------销售订单Grid-------------------------
        //销售订单Grid Store
        var statsResultDS = new Ext.data.Store({
          paramNames: {
            start: "start",
            limit: "limit"
          },
          proxy: new Ext.data.HttpProxy({
            url: '/purchase_order/getProductStockRemindForReport'
          }),
          reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
          }, [{
              name: 'id'
            },{
              name: 'name'
            },{
              name: 'number'
            },{
              name: 'min_quantity',
              type: 'int'
            },{
              name: 'max_quantity',
              type: 'int'
            },{
              name: 'quantity',
              type: 'int'
            }])
        });

        //生成销售订单Grid的CM
        var statsResultSM = new Ext.grid.CheckboxSelectionModel({singleSelect:true});
        var statsResultCM = new Ext.grid.ColumnModel({defaults: {
            sortable: true,
            menuDisabled: false
          },columns:[new Ext.grid.RowNumberer(),statsResultSM,{
              header: '产品名称',
              dataIndex: 'name',
              width: 230
            },{
              header: '产品编号',
              dataIndex: 'number',
              width: 70
            },{
              header: '预警最小值',
              dataIndex: 'min_quantity',
              align:'right',
              width: 130
            },{
              header: '预警最大值',
              dataIndex: 'max_quantity',
              align:'right',
              width: 130
            },{
              header: '当前库存数量',
              dataIndex: 'quantity',
              align:'right',
              width: 130
            }
          ]});

        //生成要订单的产品的Grid
        var statsResultGrid = new Ext.grid.GridPanel({
          title:'统计结果列表',
          store: statsResultDS,
          cm: statsResultCM,
          sm: statsResultSM,
          loadMask: true,
          width: screenWidth-175,
          height: screenHeight-300,
          frame: true         
        });    

        //总的panel
        var workbenchPanel = new Ext.Panel({
          width: screenWidth-175,
          height: screenHeight-260,
          frame:false,
          layout:'table',
          layoutConfig: {columns:1},
          defaults:{margins:'5 5 5 5'},
          items:[queryFormPanel,statsResultGrid]
        });
        workbenchPanel.render("product_stock_remind_report_workbench_panel");
      })
    </script>
  </head>
  <body>
    <div id="product_stock_remind_report_workbench_panel"></div>
  </body>
</html>